﻿using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;

namespace SLCanvas
{
    // HTML 5 Canvas Specifications
    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html
    // http://dev.w3.org/html5/spec/the-canvas-element.html

    // TODO: Implement rest of spec
    // TODO: Throw appropriate DOMException codes where relevant

    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            // Create scriptable object
            var canvas = new HTMLCanvasElement(CanvasElement);
            HtmlPage.RegisterScriptableObject(canvas.GetType().Name, canvas);

            // Pass size information on
            Loaded += delegate
            {
                CanvasElement.Width = Application.Current.Host.Content.ActualWidth;
                CanvasElement.Height = Application.Current.Host.Content.ActualHeight;
            };
        }
    }
}
